package hotel.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import hotel.service.LoginService;

@Controller
public class LoginController {
	@Resource
	LoginService loginService;
	
	@RequestMapping(produces="application/json;charset=UTF-8",
			value="judgeLogin",method= {RequestMethod.POST})
	@ResponseBody
	public Map<String,Object> judgeLogin(HttpServletRequest Request,HttpServletResponse Response,String num,String password){
		System.out.println("入口内");
		Map<String,Object> map = new HashMap<String,Object>();
		boolean whetherSucceed = loginService.judgeIogin(num, password);
		if(whetherSucceed) {
			map.put("message", "susseed to login");
			return map;
		}
		map.put("error", "fail to login");
		return map;
	}
	
}
